//
//  CinemaViewController.m
//  stotyboard豆瓣电影
//
//  Created by Zhao YanBin on 16/1/4.
//  Copyright © 2016年 panxue. All rights reserved.
//

#import "CinemaViewController.h"
#import "NetworkHandler.h"
#import "CinemaTableViewCell.h"

@interface CinemaViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property(nonatomic, strong)NSArray *dataArr;
@end

@implementation CinemaViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self data];
}

-(void)data
{
    NSString *str = @"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/cinemalist.php";
    [NetworkHandler GETWithURL:str completion:^(id result) {
        self.dataArr = result[@"result"][@"data"];
        [self.tableView reloadData];
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CinemaTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    NSDictionary *dic = _dataArr[indexPath.row];
    cell.cinemaName.text = dic[@"cinemaName"];
    cell.address.text = dic[@"address"];
    cell.telephone.text = dic[@"telephone"];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
